/*
Copyright To change this template, choose Tools | Templates
Copyright and open the template in the editor.
 */
package com.click.app.model;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 * @author Joel Chuca Condo
 * @date 07/04/2009
 */
@Entity
@Table(name = "entryProduct_details")
public class EntryProductDetail extends BaseObject {

    private Long id;
    private EntryProduct entryProduct;
    private Product product;
    //private Coin coin;
    private Integer quantity;
    private Float unitPrice;
    private Float sellPrice;
    private Integer currentQuantity;
    private Float totalPrice;
    private Float discountXfail;
    private Float quantityFail;
    private Boolean deleted;
    
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id_entryProduct_detail", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @ManyToOne
    @JoinColumn(name = "id_entryProduct", nullable = false)
    public EntryProduct getEntryProduct() {
        return this.entryProduct;
    }

    public void setEntryProduct(EntryProduct entryProduct) {
        this.entryProduct = entryProduct;
    }

    @ManyToOne(optional=true)
    @JoinColumn(name = "id_product")
    public Product getProduct() {
        return this.product;
    }

    public void setProduct(Product product) {
        this.product = product;
    }

    @Column(name = "discount_x_fail")
    public Float getDiscountXfail() {
        return discountXfail;
    }

    public void setDiscountXfail(Float discountXfail) {
        this.discountXfail = discountXfail;
    }

    @Column(name = "quantity_fail")
    public Float getQuantityFail() {
        return quantityFail;
    }

    public void setQuantityFail(Float quantityFail) {
        this.quantityFail = quantityFail;
    }

/*
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "id_coin", nullable = false)
    public Coin getCoin() {
        return this.coin;
    }

    public void setCoin(Coin coins) {
        this.coin = coin;
    }
*/
    @Column(name = "unit_price", precision = 12, scale = 0)
    public Float getUnitPrice() {
        return this.unitPrice;
    }

    public void setUnitPrice(Float unitPrice) {
        this.unitPrice = unitPrice;
    }

    @Column(name = "total_price", precision = 12, scale = 0)
    public Float getTotalPrice() {
        return this.totalPrice;
    }

    public void setTotalPrice(Float totalPrice) {
        this.totalPrice = totalPrice;
    }
    /*
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "entryProductDetails")
    public Set<ProductReturns> getProductReturnses() {
        return this.productReturnses;
    }

    public void setProductReturnses(Set<ProductReturns> productReturnses) {
        this.productReturnses = productReturnses;
    }*/

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof EntryProductDetail)) {
            return false;
        }
        EntryProductDetail other = (EntryProductDetail) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.click.app.model.EntryProductDetail[id=" + id + ", quantity="+getQuantity()+"]";
    }

    /**
     * @return the quantity
     */
    public Integer getQuantity() {
        return quantity;
    }

    /**
     * @param quantity the quantity to set
     */
    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    /**
     * @return the currentQuantity
     */
    public Integer getCurrentQuantity() {
        return currentQuantity;
    }

    /**
     * @param currentQuantity the currentQuantity to set
     */
    public void setCurrentQuantity(Integer currentQuantity) {
        this.currentQuantity = currentQuantity;
    }

    /**
     * @return the deleted
     */
    public Boolean getDeleted() {
        return deleted;
    }

    /**
     * @param deleted the deleted to set
     */
    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    /**
     * @return the sellPrice
     */
    public Float getSellPrice() {
        return sellPrice;
    }

    /**
     * @param sellPrice the sellPrice to set
     */
    public void setSellPrice(Float sellPrice) {
        this.sellPrice = sellPrice;
    }

}
